Next: 2.4.6 Windows Install Using Up: 2.4 Building SDCC Previous: 2.4.4 Building SDCC using Contents Index

## 2.4.5 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)

Download the source package either from the SDCC Subversion repository or from the snapshot builds `http://sdcc.sourceforge.net/snap.php`, it will be named something like sdcc-src-yyyymmdd-rrrr.tar.bz2. SDCC is distributed with all the projects, workspaces, and files you need to build it using Visual C++ 6.0/NET (except for SDCDB and ucSim). The workspace name is 'sdcc.dsw'. Please note that as it is now, all the executables are created in a folder called sdcc\bin_vc. Once built you need to copy the executables from sdcc\bin_vc to sdcc\bin before running SDCC.
WARNING: Visual studio is very picky with line terminations; it expects the 0x0d, 0x0a DOS style line endings, not the 0x0a Unix style line endings. When using the Subversion repository it's easiest to configure the svn client to convert automatically for you. If however you are getting a message such as This makefile was not generated by Developer Studio etc. etc.'' when opening the sdcc.dsw workspace or any of the *.dsp projects, then you need to convert the Unix style line endings to DOS style line endings. To do so you can use the ''unix2dos'' utility freely available on the internet. Doug Hawkins reported in the sdcc-user list that this works:
C:\Programming\SDCC> unix2dos sdcc.dsw
C:\Programming\SDCC> for /R %I in (*.dsp) do @unix2dos %I
In order to build SDCC with MSVC you need win32 executables of bison.exe, flex.exe, and gawk.exe. One good place to get them is here `http://unxutils.sourceforge.net`
Download the file UnxUtils.zip. Now you have to install the utilities and setup MSVC so it can locate the required programs. Here there are two alternatives (choose one!):

1. The easy way:
   a) Extract UnxUtils.zip to your C:\ hard disk PRESERVING the original paths, otherwise bison won't work. (If you are using WinZip make certain that 'Use folder names' is selected)
   b) In the Visual C++ IDE click Tools, Options, select the Directory tab, in 'Show directories for:' select 'Executable files', and in the directories window add a new path: 'C:\user\local\wbin', click ok.
   (As a side effect, you get a bunch of Unix utilities that could be useful, such as diff and patch.)
2. A more compact way:
   This one avoids extracting a bunch of files you may not use, but requires some extra work:
   a) Create a directory were to put the tools needed, or use a directory already present. Say for example 'C:\util'.
   b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and gawk.exe to such directory WITHOUT preserving the original paths. (If you are using WinZip make certain that 'Use folder names' is not selected)
   c) Rename bison.exe to '_bison.exe'.
   d) Create a batch file 'bison.bat' in 'C:\util\' and add these lines:
   set BISON_SIMPLE=C:\util\bison.simple
   set BISON_HAIRY=C:\util\bison.hairy
   _bison %1 %2 %3 %4 %5 %6 %7 %8 %9
   Steps 'c' and 'd' are needed because bison requires by default that the files 'bison.simple' and 'bison.hairy' reside in some weird Unix directory, '/usr/local/share/' I think. So it is necessary to tell bison where those files are located if they are not in such directory. That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.
   e) In the Visual C++ IDE click Tools, Options, select the Directory tab, in 'Show directories for:' select 'Executable files', and in the directories window add a new path: 'c:\util', click ok. Note that you can use any other path instead of 'c:\util', even the path where the Visual C++ tools are, probably: 'C:\Program Files\Microsoft Visual Studio\Common\Tools'. So you don't have to execute step 'e' :)

That is it. Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy the executables from sdcc\bin_vc to sdcc\bin, and you can compile using SDCC.

Next: 2.4.6 Windows Install Using Up: 2.4 Building SDCC Previous: 2.4.4 Building SDCC using Contents Index